//1、对数组进行解构
let arr1 = [0,1,2,3,4,5]

console.log('arr1[0]',arr1[0])

let [a,b,c,d] = arr1
console.log(a,b,c,d)

//2、对对象进行解构
const person = {
    name:'lily',
    age:18,
    address:'深圳'
}

//如果想自动推导需要写成同名，否则要自己指定
let {name,age,address} = person
console.log(name,age,address)
//指定就不需要考虑顺序
let {name:name1,address:address1,age:age1} = person
console.log(name1,age1,address1)

//3、当对象作为函数参数时，也可以解构
const person1 = {name:'小明',age:'11'}

function printPerson1({name, age}) {
    console.log(`姓名：${name}年龄：${age}`);
    //反引号括起来，美元符号里面放变量
}
//3、当对象作为函数参数时，也可以解构,函数里面需要花括号括起来
printPerson1(person1)